﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Player.DengLu
{
    public partial class zhuche : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //登录
        protected void btn_DengLu_Click(object sender, EventArgs e)
        {
            //获取输入内容
            string Usname = this.txt_UserName.Text.Trim();
            string Pwd = this.txt_Password.Text.Trim();
            string phone = this.txt_phone.Text.Trim();
            //判断输入
            bool blname = true;
            bool blpwd = true;
            bool blphone = true;
            bool blCunZai = true;
            //提示
            //用户名判断
            if (Usname.Length == 0)
            {
                blname = false;
                this.lbl_name.Text = "请输入用户名";
            }
            else
            {
                this.lbl_name.Text = "";
            }
            //密码判断
            if (Pwd.Length == 0)
            {
                blpwd = false;
                this.lbl_pwd.Text = "请输入密码";
            }
            else
            {
                this.lbl_pwd.Text = "";
            }
            //电话判断
            if (phone.Length == 0)
            {
                blphone = false;
                this.lbl_phone.Text = "请输入电话";
            }
            else
            {
                this.lbl_phone.Text = "";
            }
            if (phone.Length != 11)
            {
                blphone = false;
                this.lbl_phone.Text = "号码长度为11位";
            }
            else
            {
                this.lbl_phone.Text = "";
            }
            if (blname == false || blpwd == false || blCunZai == false || blphone==false)
            {
                return;
            }
            else
            {
                //添加用户
                Users us = new Users();
                us.Us_Account = Usname;
                us.Us_Password = Pwd;
                us.Us_Phone = phone;
                us.Us_Sex='无';
                us.Us_Name = "用户";
                us.Us_Balance = 500;
                us.Us_Goid = 100;
                bool zcbl = BLL.UsersManage.AddTYUsers(us);
                if (zcbl)
                {
                    this.lbl_dlts.Text = "注册成功";
                }
                else
                {
                    this.lbl_dlts.Text = "注册失败";
                }
            }

        }
        //返回
        protected void img_TuiChu_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("DLindex.aspx");
        }
    }
}